<?php
class Sfs_View_Helper_YearSemester
{

	private $_data;
	/**
	 * 回傳學年學期陣列
	 *
	 * @param 額外設定 $arr
	 * $arr['date'] 基準日期
	 * $arr['order'] 排序方式
	 *
	 * @return array
	 */
	function YearSemester($arr=array()){
		$semester = new Semester_Model_DbTable_SemesterDuration();
		$date = date("Y-m-d");
		if (isset($arr['date']))
			$date = $arr['date'];
		$order = array('year','semester');
		if (isset($arr['order']))
			$order = $arr['order'];

		$this->_data = $semester->fetchAll("started_date<='$date'",$order)->toArray();
		//$str = '<select id="'.$name.'" name="'.$name.'">';
		//foreach($res as $val) {
		//	$str .= '<option value="'.$val['year'].'-'.$val['semester'].'">'.$val['year'].'學年第'.$val['semester'].'學期</option>';
	//	}
		//$str .='</select>';
		return $this->_data;
	}

}